<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../application/vue.js"></script>
    <style>
        .h1{
            background-color:aqua;
            position:absolute;
            width:100%;
        }
        .h2{
            background-color:chartreuse;
            position:absolute;
            width:100%;
        }
        .start{
            opacity:1;
            transform:translateX(0);
        }
        .active{
            transition:all 2s ease ;
        }
        .end{
            opacity:0;
            transform:translateX(-100%);
        }
        .start1{
            opacity:0;
            transform:translateX(100%);
        }
        .active1{
            transition:all 2s ease ;
        }
        .end1{
            opacity:1;
            transform:translateX(0);
        }
    </style>
</head>
<body>
    <div id="app">
        <input type="button" value="过渡组件" @click="flag=!flag">
        <hr>
        <!-- <transition 
            enter-class="start1"
            enter-active-class="active1"
            enter-to-class="end1"
            leave-class="start"
            leave-active-class="active"
            leave-to-class="end"
        >      
            <h1 class="h2" v-if="flag">王梦云</h1>       
        </transition> -->
        <transition-group
            enter-class="start1"
            enter-active-class="active1"
            enter-to-class="end1"
            leave-class="start"
            leave-active-class="active"
            leave-to-class="end"
        >
            <h1 class="h1" v-if="flag" key="group1">王梦云</h1>       
            <h1 class="h2" v-if="!flag" key="group2">王梦云</h1>       
        </transition-group>

    </div>
</body>
<script>
    new Vue({
        el:"#app",
        data:{
            flag:true
        }
    })
</script>
</html>